package com.example.demo.po;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

@EntityListeners(AuditingEntityListener.class)
@DynamicUpdate
@MappedSuperclass
@Data
public class AuditEntity{

    @Id
    @Column(name="ID",length=64)
    @GenericGenerator(name="uuid",strategy = "uuid")
    @GeneratedValue(generator = "uuid")
    private String id;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @Column(name = "CRT_TM", columnDefinition = "datetime comment '创建时间'")
    @CreatedDate
    private Date createdAt;
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @Column(name = "MOD_TM", columnDefinition = "datetime comment '修改时间'")
    @LastModifiedDate
    private Date modifiedAt;
    /**
     * 创建者ID.
     */
    @Column(name = "CRTR_ID", columnDefinition = "varchar(64) comment '创建人ID'")
    private String createUserId;

    /**
     * 创建者名称.
     */
    @Column(name = "CRTR_NM", columnDefinition = "varchar(64) comment '创建人姓名'")
    private String createUserName;

    /**
     * 修改者ID.
     */
    @Column(name = "MOD_ID", columnDefinition = "varchar(64) comment '修改者ID'")
    private String modifiedId;


    /**
     * 是否删除标志 0-否 1- 是
     */
    @Column(name="DEL_FLG",columnDefinition = "int comment '删除标志'")
    private Integer deleteFlg = 0;

}
